#pragma once
#include <sys/time.h>
#include <sys/epoll.h>
#include <pthread.h>
#include <netinet/in.h>

#include <map>
#include <string>
#include <deque>

#include "Loop.h"
#include "ThreadPool.h"

namespace sevent{

class Server
{
public:
	typedef boost::function <int (Connect *, char*)> TaskFunc;
	Server(const std::string name, const std::string ip, const int port, const TaskFunc &f);
	Server(const std::string name, const std::string ip, const int port);
	virtual ~Server();

	int start(int threadNum);
	int stop();
	int wait();

	bool started() const {
		return _started;
	}
	const std::string name() const {
	} 

	ThreadPool &getThreadPool(){return _threadPool;}
	Loop &getLoop(){return _loop;}
	
	void setTaskFunc(TaskFunc f);
	TaskFunc& getTaskFunc(){return _taskFunc;}
	
	
	std::string &name(){
		return _name;
	}

private:
	std::string _name;
	bool _started;

	TaskFunc _taskFunc;
	
	Loop _loop;
	ThreadPool _threadPool;
	
};


}

